/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace ELE.EnterpriseLibrary.Data.Configuration
{
  /// <summary>
  /// Defines the basic data in the configuration file for describing a property to column binding.
  /// <seealso cref="PropertyBindingData"/> and <seealso cref="PropertyBindingOverwriteData"/>
  /// </summary>
  public class BasePropertyBindingData : NamedConfigurationElement
  {
    private const string inNameProperty = "inName";
    private const string outNameProperty = "outName";
    private const string nullableValueProperty = "nullableValue";
    private const string ignoreProperty = "ignore";
    /// <summary>
    /// Default constructor.
    /// </summary>
    public BasePropertyBindingData() { }
    /// <summary>
    /// Named constructor.
    /// </summary>
    /// <param name="name"></param>
    public BasePropertyBindingData(string name) : base(name) { }
    /// <summary>
    /// The name of the input parameter to be used in the sql queries that use this binding.
    /// </summary>
    [ConfigurationProperty(inNameProperty, IsRequired = false)]
    public string InName
    {
      get { return (string)base[inNameProperty]; }
      set { base[inNameProperty] = value; }
    }
    /// <summary>
    /// The name of the output parameter from the sql query that uses this binding.
    /// </summary>
    [ConfigurationProperty(outNameProperty, IsRequired = false)]
    public string OutName
    {
      get { return (string)base[outNameProperty]; }
      set { base[outNameProperty] = value; }
    }
    /// <summary>
    /// The string representation of a value that represents a <see cref="System.DBNull"/> in the database.
    /// </summary>
    [ConfigurationProperty(nullableValueProperty, IsRequired = false)]
    public string NullableValue
    {
      get { return (string)base[nullableValueProperty]; }
      set { base[nullableValueProperty] = value; }
    }
    /// <summary>
    /// Flag to ignore this binding from sql queries.
    /// </summary>
    [ConfigurationProperty(ignoreProperty, IsRequired = false, DefaultValue = false)]
    public bool Ignore
    {
      get { return (bool)base[ignoreProperty]; }
      set { base[ignoreProperty] = value; }
    }
  }
}
